﻿// <copyright file="AddInActivationPolicy.cs" company="Anatoly Sereda">
// © 2009 Anatoly Sereda
//
// This source is subject to the Microsoft Public License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Anatoly Sereda</author>
// <email>neonnvr@live.com</email>
// <date>2009-08-04</date>

using System;
using System.AddIn.Hosting;
using System.Security;

namespace MafMefInterop
{
	public class AddInActivationPolicy
	{
		public AddInActivationPolicy(AddInEnvironment environment)
		{
			this.Environment = environment;
		}

		public AddInActivationPolicy(AddInSecurityLevel trustLevel)
		{
			this.TrustLevel = trustLevel;
		}

		public AddInActivationPolicy(AppDomain target)
		{
			this.AppDomain = target;
		}

		public AddInActivationPolicy(PermissionSet permissions)
		{
			this.Permissions = permissions;
		}

		public AddInActivationPolicy(AddInProcess process, AddInSecurityLevel level)
		{
			this.Process = process;
			this.TrustLevel = level;
		}

		public AddInActivationPolicy(AddInProcess process, PermissionSet permissionSet)
		{
			this.Process = process;
			this.Permissions = permissionSet;
		}

		public AddInActivationPolicy(AddInSecurityLevel trustLevel, string appDomainName)
		{
			this.TrustLevel = trustLevel;

			if (string.IsNullOrEmpty(appDomainName))
			{
				this.AppDomainName = appDomainName;
			}
		}

		internal AddInEnvironment Environment { get; private set; }

		internal AddInSecurityLevel? TrustLevel { get; private set; }

		internal AppDomain AppDomain { get; private set; }

		internal PermissionSet Permissions { get; private set; }

		internal AddInProcess Process { get; private set; }

		internal string AppDomainName { get; private set; }
	}
}
